#ifndef CSE168_BL_PATCH_H_INCLUDED
#define CSE168_BL_PATCH_H_INCLUDED

#include "Vector3.h"
#include "Object.h"

class BLPatch : public Object
{
public:
    BLPatch();
    virtual ~BLPatch();

    Vector3 & vertex(int i)             {return m_verts[i];}
    const Vector3 & vertex(int i) const {return m_verts[i];}
    
    void setVertex(int i, Vector3 val){ m_verts[i] = val; }

    virtual void renderGL();
    virtual bool intersect(HitInfo& result, const Ray& ray,
                           float tMin = 0.0f, float tMax = MIRO_TMAX);

protected:

   float getU(float v);
   bool solve(const Ray& ray, HitInfo& hit, float v, float tMin, float tMax);

   Vector3 m_verts[4];
   Vector3 a,b,c,d;
   float A[2], B[2], C[2], D[2];
};

#endif // CSE168_BL_PATCH_H_INCLUDED
